package net.rock.service;

import net.rock.pojo.Cart;
import net.rock.mapper.CartMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartService {
    @Autowired
    private CartMapper cartMapper;

    public List<Cart> fetchCarts(Integer userId) {
        return cartMapper.fetchCarts(userId);
    }

    public void add(Cart cart) {
        cartMapper.add(cart);
    }

    public void del(int userId, int bookId) {
        Cart cart = new Cart(bookId, userId, 0);
        cartMapper.del(cart);
    }

    public void edit(Cart cart) {
        cartMapper.edit(cart);
    }
}